<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>我的购物车——小米商城</title>
<link rel="shortcut icon" href="//s01.mifile.cn/favicon.ico"
	type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/shopping-car2.css">
<style type="text/css">
/* 头像 */
.thumFace {
	width: 28px;
	height: 28px;
	border-radius: 14px;
	vertical-align: -8px;
	margin-right: 15px;
}
</style>
</head>

<body>
	<div class="site-header site-mini-header">
		<div class="container">
			<div class="header-logo">
				<a class="logo ir" href="index.jsp" title="小米官网"> ::before 小米官网
					::after </a>
			</div>
			<div class="header-title has-more" id="J_miniHeaderTitle">
				<h2>我的购物车</h2>
				<p>温馨提示：产品是否购买成功，以最终下单为准哦，请尽快结算</p>
			</div>
			<div class="topbar-info" id="J_userInfo">
				<%
					String loginImg = (String) session.getAttribute("simg");
					if (loginImg != null) {
						String user = session.getAttribute("simg").toString();
						out.print("<img class = 'thumFace' src='" + loginImg + "'>");
					}
				%>
				<%
					String loginName = (String) session.getAttribute("sname");
					String loginTel = (String) session.getAttribute("stel");
					if (loginName != null) {
						// 用户已登录
						String user = session.getAttribute("sname").toString();
						out.print("<a href = 'userinfo.jsp' id = 'userInfo'>" + user + "<a/>");
						out.print("<span> |</span> ");
						out.print("<a href='logout.jsp'>退出</a> ");
					} else if (loginTel != null) {
						// 用户已登录
						String user = session.getAttribute("stel").toString();
						out.print("<a href = 'userinfo.jsp' id = 'userInfo'>" + user + "<a/>");
						out.print("<span>|</span> ");
						out.print("<a href='logout.jsp'>退出</a> ");
					} else {
						// 用户未登录
						out.print("<a href='loading.jsp' id = 'userName'>登录</a>");
						out.print("<span>|</span> ");
						out.print("<a href='register.jsp'>注册</a> ");
					}
				%>
			</div>
		</div>
	</div>
	<script>
		var SiteCloseTipShow = 1;
	</script>
	<div class="page-main">

		<div class="container">
			<div class="cart-loading loading hide" id="J_cartLoading">
				<div class="loader"></div>
			</div>
			<div class="cart-empty hide" id="J_cartEmpty">
				<h2>您的购物车还是空的！</h2>
				<p class="login-desc">登录后将显示您之前加入的商品</p>
				<a href="#" class="btn btn-primary btn-login" id="J_loginBtn"
					data-stat-id="59e2bd53cad630cd"
					onclick="_msq.push(['trackEvent', '5df97b551662ffe7-59e2bd53cad630cd', '#', 'pcpid', '']);">立即登录</a>
				<a href="//list.mi.com/0"
					class="btn btn-primary btn-shoping J_goShoping"
					data-stat-id="4fa3bed319799708"
					onclick="_msq.push(['trackEvent', '5df97b551662ffe7-4fa3bed319799708', '//list.mi.com/0', 'pcpid', '']);">马上去购物</a>
			</div>
			<div id="J_cartBox" class="">
				<div class="cart-goods-list">
					<div class="list-head clearfix">
						<div class="col col-check">
							<i class="iconfont icon-checkbox icon-checkbox-selected"
								id="J_selectAll">√</i>全选
						</div>
						<div class="col col-img">&nbsp;</div>
						<div class="col col-name">商品名称</div>
						<div class="col col-price">单价</div>
						<div class="col col-num">数量</div>
						<div class="col col-total">小计</div>
						<div class="col col-action">操作</div>
					</div>
					<div class="list-body" id="J_cartListBody">
						<div class="item-box">
							<div id="displaytbody" class="item-table J_cartGoods">
								
							</div>
						</div>
					</div>
				</div>
				<!-- 加价购 -->

				<div class="raise-buy-box " id="J_raiseBuyBox "></div>

				<div class="cart-bar clearfix cart-bar-fixed " id="J_cartBar ">
					<div class="section-left ">
						<a href="//list.mi.com/0 " class="back-shopping J_goShoping "
							data-stat-id="2506fe513b60baa9 "
							onclick="_msq.push([ 'trackEvent', '5df97b551662ffe7-2506fe513b60baa9', '#', 'pcpid', '']); ">继续购物</a>
						<span class="cart-total ">共 <i id="J_cartTotalNum ">3</i>
							件商品，已选择 <i id="J_selTotalNum ">3</i> 件
						</span> <span class="cart-coudan hide " id="J_coudanTip "> ，还需 <i
							id="J_postFreeBalance ">0.00</i> 元即可免邮费 <a
							href="javascript:void(0); " id="J_showCoudan "
							data-stat-id="fb044ca506d838e1 "
							onclick="_msq.push([ 'trackEvent', '5df97b551662ffe7-fb044ca506d838e1', 'javascript:void0', 'pcpid', '']); ">立即凑单</a>
						</span>
					</div>
					<span class="activity-money hide "> 活动优惠：减 <i id="J_cartActivityMoney ">0</i>元</span>
					<span class="total-price " id = "ccon"></span>
					<!--  合计：<em id="J_cartTotalPrice ">0</em>元 -->
					<%
						session.setAttribute("total", 2599);
					%>
					<a href="shoppingcar-jiesuan.jsp" class="btn btn-a btn btn-primary">去结算</a>
					<div class="no-select-tip hide " id="J_noSelectTip ">
						请勾选需要结算的商品 <i class="arrow arrow-a "></i> <i
							class="arrow arrow-b "></i>
					</div>

					<div class="site-footer container cleFloat">
						<div class="footer-service">
							<ul>
								<li><img src="img/sitefooter/weixiu.png" /> 预约维修服务</li>
								<li><img src="img/sitefooter/7天.png" /> 7天无理由退货</li>
								<li><img src="img/sitefooter/15天.png" /> 15天免费换货</li>
								<li><img src="img/sitefooter/包邮.png" /> 满150元包邮</li>
								<li><img src="img/sitefooter/定位.png" /> 520余家售后服务点</li>
							</ul>
						</div>
						<div class="footer-links">
							<dl>
								<dt>帮助中心</dt>
								<dd>
									<a>账户管理</a>
								</dd>
								<dd>
									<a>购物指南</a>
								</dd>
								<dd>
									<a>订单操作</a>
								</dd>
							</dl>
							<dl>
								<dt>服务支持</dt>
								<dd>
									<a>售后政策</a>
								</dd>
								<dd>
									<a>自助服务</a>
								</dd>
								<dd>
									<a>相关下载</a>
								</dd>
							</dl>
							<dl>
								<dt>线下门店</dt>
								<dd>
									<a>小米之家</a>
								</dd>
								<dd>
									<a>服务站点</a>
								</dd>
								<dd>
									<a>授权体验店</a>
								</dd>
							</dl>
							<dl>
								<dt>关于小米</dt>
								<dd>
									<a>了解小米</a>
								</dd>
								<dd>
									<a>加入小米</a>
								</dd>
								<dd>
									<a>投资者关系</a>
								</dd>
							</dl>
							<dl>
								<dt>关注我们</dt>
								<dd>
									<a>新浪微博</a>
								</dd>
								<dd>
									<a>官方微信</a>
								</dd>
								<dd>
									<a>联系我们</a>
								</dd>
							</dl>
							<dl>
								<dt>特色服务</dt>
								<dd>
									<a>F码通道</a>
								</dd>
								<dd>
									<a>礼物吗</a>
								</dd>
								<dd>
									<a>防伪查询</a>
								</dd>
							</dl>
							<div class="col-contact">
								<p>400-100-5678</p>
								<p>周一至周日 8:00-18:00</p>
								<p>（仅收市话费）</p>
								<div class="nofollow">
									<a>联系客服</a>
								</div>
							</div>
						</div>
					</div>

					<div class="site-info cleFloat">
						<div class="container">
							<div class="info-text">
								<p>
									<a>小米商城</a> <span>|</span> <a>MIUI</a> <span>|</span> <a>米家</a>
									<span>|</span> <a>米聊</a> <span>|</span> <a>多看</a> <span>|</span>
									<a>游戏</a> <span>|</span> <a>路由器</a> <span>|</span> <a>米粉卡</a> <span>|</span>
									<a>政企服务</a> <span>|</span> <a>小米天猫店</a> <span>|</span> <a>隐私政策</a>
									<span>|</span> <a>问题反馈</a> <span>|</span> <a>廉政举报</a> <span>|</span>
									<a>Select Region</a>
								</p>
								<p>
									@ <a>mi.com</a> 京ICP证110507号 <a>京ICP备10046444号</a> <a>京公网安备11010802020134号</a>
									<a>京网文[2017]1530-131号 </a> <br />
									违法和不良信息举报电话：185-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试
								</p>


							</div>
							<div class="info-links">
								<img src="img/sitefooter/truste.png" /> <img
									src="img/sitefooter/v-logo-2.png" /> <img
									src="img/sitefooter/v-logo-1.png" /> <img
									src="img/sitefooter/v-logo-3.png" /> <img
									src="img/sitefooter/ba10428a4f9495ac310fd0b5e0cf8370.png" />
							</div>
						</div>
						<div class="slogan">
							<span>探索黑科技，小米为发烧而生！</span>
						</div>
					</div>


					<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
					<script type="text/javascript" src="js/index.js"></script>


				</div>
			</div>

			<script type="text/javascript">
				$(function() {
					$.ajax({
						url : "QueryShopcartAction",
						type : "POST",
						dataType : "json",
						success : function(result) {
							// 回调函数的DOM操作
							// 解析json数据
							console.info(result);
							var count = 0;
							// 解析拼写的html内容
							var strHtml = "";
							$.each(result,function(index, eachVal) {
									strHtml += " <div class='item-row clearfix'> ";
									strHtml += " <div class='col col-check'> ";
									strHtml += " <i class='iconfont icon-checkbox icon-checkbox-selected  ";
									strHtml += " J_itemCheckbox' data-itemid='2182100031_0_buy' ";
									strHtml += " data-status='1'> ";
									strHtml += " √</i> ";
									strHtml += " </div> ";
									strHtml += " <div class='col col-img'> ";
									strHtml += " <img src=' ";
									
									strHtml += eachVal.goods_img;
									
									strHtml += " ' width='80' height='80'> ";
									strHtml += " </div> ";
									strHtml += " <div class='col col-name'> ";
									strHtml += " <h3 class=' name '> ";
									
									strHtml += eachVal.goods_name;
			
									strHtml += " </h3> ";
									strHtml += " </div> ";
									strHtml += " <div class='col col-price '> ";
									
									strHtml += eachVal.goods_price;
									strHtml += " 元</div> ";
									strHtml += " <div class='col col-num '> ";
									strHtml += " <div class='change-goods-num clearfix J_changeGoodsNum '> ";
			
									strHtml += " <a class='J_minus '> ";
									strHtml += " <i class='iconfont '>-</i> ";
									strHtml += " </a> ";
									strHtml += " <input tyep='text' name='2182100031_0_buy' ";
									strHtml += " value='1' ";
									
									strHtml += " class= 'goods-num J_goodsNum' ";
									strHtml += " <a class=' J_plus '> ";
									strHtml += " <i class='iconfont'> + </i> ";
									
									strHtml += " </a></div> ";
									strHtml += " </div> ";
									strHtml += " <div class='col  col-total '> ";
			
									strHtml += eachVal.counts;
									
									count += eachVal.counts
									console.info(count);
									strHtml += " 元</div> ";
									strHtml += "<div class='col col-action  '>";
									strHtml += "";
									strHtml += " <a id='2182100031_0_buy' class='del J_delGoods'> ";
									strHtml += " <i class='iconfont '>×</i>";
									strHtml += "</a></div>";
									strHtml += "</div>";
				
								});
							console.info(count);
							var stt = "";
							stt += " 合计：<em id='J_cartTotalPrice '>";
							stt += count;
							stt += " </em>元  ";
							// 把解析的html内容，使用dom操作赋值到表格中
							$("#displaytbody").html(strHtml);
							$("#ccon").html(stt);
						},
						error : function(result) {
							alert("请求失败" + result);
						}
					});
				});
			</script>
</body>
</html>